import pytest

from testcases.usercenter.conftest import user_id
from utils.log_util import logger
from utils.mysql_util import db


@pytest.fixture()
def banner_num():
    sql = "select count(1) as banner_num from goods_banner"
    result = db.select_db_one(sql)
    return result['banner_num']


def get_shop_cart_num(username, good_id):
    # 查询UID
    userid = user_id(username)
    sql = "select nums from trade_shoppingcart where user_id = %d and goods_id = %d" % (userid, good_id)
    result = db.select_db_one(sql)
    logger.info(f'sql执行的结果:{result}')
    return result['nums']
